A histogram shows you the composition of a photo in terms of its light levels. The histogram shows how the pixels of the photo are distributed on a dark to light scale.

An example histogram with good pixel distribution.
The histogram starts with black on the far left, and ends with white on the far right. A good photo will generally have even pixel distribution across the entire histogram.
Photos with lots of pixels clustered in the dark to mid-tone (or shadows) range may be underexposed, i.e. too dark.
Photos that have a high concentration of pixels in the mid-tone to light (or highlights) range may be overexposed, ie. too light.
Altering levels involves a certain amount of experimenting to get the required result. You can at any time click the Reset button to return to your original photo.
When making alterations, you can click Compare to temporarily bring back the original photo to see it. Click Compare again to reapply your changes.
There are two levels of automatically correcting levels, which may be suitable for general photo usage. But their effectiveness will depend on the photo itself.

This is a one-click approach to improve the levels of your photo. XPE will redistribute the pixels automatically to try to give a better range.
With the color pickers, you can specify colors on your photos and XPE will extrapolate what the levels should be based upon your choices.
Manually correcting levels will give you much great control, and potentially better results, than the automatic methods described earlier in the chapter.
When a picture is lacking in one end of the histogram, you can redistribute the pixels so that a greater range is achieved. If the photo is lacking in lighter colors, you can pull in the white slider to around the end of the existing histogram. XPE shows a new histogram in red to show you the new pixel distribution.

Illustrating underexposure correction
The end result with the change illustrated above is that more light pixels are included, providing the picture with better tonal range. To correct overexposure, you would perform the same action but move the black triangle to the beginning of the histogram thus providing more dark colors.
This photo is not really under or overexposed, but as it is clustered in the mid-tones it lacks vibrancy due to its lack of dark or light colors. By bringing in both the light and dark input levels, colors are richer and clearer giving the picture more life.

Before and after levels correction
The input levels of the photo are indicated in the fields at the top.
The defaults are 0 for the black point, 1.00 for the mid-tones and 255 for the white point. As you change the level, these numbers will alter to reflect your changes.
You can type numbers into the fields if you wish to manually set levels.
By default, all changes to the histogram are made to the entire joined RGB photo. This will be suitable for most levels correction.
But if you find your image has a color cast problem (it has a red, green or blue tinge) you can manually correct the levels of a specific color.
From the Channel list, select the color you wish correct.
Moving the gray mid-tones slider right will add more of that color. Moving it left will provide more of its opposite color.
Tip: as well as correcting problems, adjusting the levels of a particular color can be used if you wish to deliberately shift the photo so that it has a tint.
Input levels, as described so far in the chapter, allow for the optimization of black to white pixels across the full colour range of 0 (black) to 255 (white).
Output levels allow you to restrict the range of pixels available in the photograph, thus decreasing the contrast in the photo.
A setting of 20 and 235 for example would eliminate all pixels between 1 and 19 and 236 and 255. The photograph would not be able to use them, and your photo would shift more to the mid-tones.
Using the output levels on a particular channel will restrict or increase the use of that particular color in the photo.